home *** CD-ROM | disk | FTP | other *** search
- (*
-
- This is just a quick hack to check the Queue ADT.
- Written by P.Fröhlich 03-Sep-1991.
- Removed SYSTEM dependency [phf] 08-Sep-1991.
-
- This example shows how to deal with type-extension.
-
- *)
-
- MODULE TestQueue;
-
- IMPORT
- st : Queue,
- (* NoGuru,
- Break,*)
- io : termio; (* same as io, has all workbench stuff removed *)
-
- TYPE
- MyElement = POINTER TO MyElementObject;
-
- MyElementObject = RECORD (st.ElementObject);
- int : INTEGER;
- c : CHAR;
- l : LONGINT;
- END;
-
- VAR
- i : INTEGER;
- myQueue : st.Queue;
- myElement : MyElement; (* we need this for creation only *)
- element : st.Element;
-
- BEGIN
- st.Create(myQueue);
- IF (myQueue # NIL) THEN
- i := 0;
-
- WHILE (i < 20) DO
- NEW(myElement);
- myElement.int := i;
- myElement.c := CHR(i+65);
- myElement.l := i * i;
- st.Put(myQueue,myElement);
- INC(i);
- END;
-
- WHILE NOT st.Empty(myQueue) DO
- element := st.Get(myQueue);
- IF (element IS MyElement) THEN
- WITH element : MyElement DO
- io.WriteInt(element.int,10); io.WriteString(" ");
- io.Write(element.c);
- io.WriteInt(element.l,10);
- END;
- ELSE
- io.WriteString("Illegal stack content!\n");
- END;
- io.WriteLn;
- DISPOSE(element);
- END;
- END;
- CLOSE
- IF (myQueue # NIL) THEN st.Discard(myQueue) END;
- END TestQueue.
-